
var paypal_cost = 0;
var delivery_cost = 0;
var saddle_cost;

function calculate_costs () {
	
  paypal_cost = 0;
  delivery_cost = 0;	
  //Saddle cost
  saddle_cost = document.purchase_form.saddle_cost.value
  //Collection
  if ( document.purchase_form.delivery_options_0.checked ) 
  
     {
		 delivery_cost = 0;
	 }
  
  //Delivery
  if ( document.purchase_form.delivery_options_1.checked ) 
  
  	 {
		 delivery_cost = 13.00;
		 document.purchase_form.payment_options_1.checked = "true";
	 
	 }
  
  //Cash payment
  if ( document.purchase_form.payment_options_0.checked ) {paypal_cost = 0;}
  //Paypal
  if ( document.purchase_form.payment_options_1.checked ) 
  	 
	 {
		 paypal_cost = ((saddle_cost / 100) * 3.4) + 0.20;
	 }
    	 
  saddle_cost =  parseFloat(saddle_cost);
  
  total_cost = paypal_cost + delivery_cost;
  total_cost = total_cost + saddle_cost;
  total_cost = total_cost.toFixed(2);
  
  delivery_cost = delivery_cost.toFixed(2);
  paypal_cost = paypal_cost.toFixed(2);
  
  document.getElementById('delivery_cost_display').innerHTML = delivery_cost;
  document.getElementById('paypal_cost_display').innerHTML = paypal_cost;
  
  //Total cost
  document.getElementById('total_cost_display').innerHTML = total_cost;

  //alert(delivery_cost);

  //calculate_cost ()
  
}

function continue_payment () {


  collection = document.purchase_form.delivery_options_0.checked;
  delivery = document.purchase_form.delivery_options_1.checked;
  cash = document.purchase_form.payment_options_0.checked;
  paypal = document.purchase_form.payment_options_1.checked;
  
  if(collection == true || delivery == true){delivery_complete = 1;} else {delivery_complete = 0;}
  if(cash == true || paypal == true){payment_complete = 1;} else {payment_complete = 0;}

  <!--PAYPAL PAYMENT -->

	if(paypal == true)
	
	{

  		if(delivery_complete == 1 && payment_complete == 1)
  
  		{
		alert("You will now be redirected to PayPal's secure checkout");
		
		saddle_cost =  parseFloat(saddle_cost);
		paypal_cost =  parseFloat(paypal_cost);
		
		item_cost = (saddle_cost + paypal_cost).toFixed(2);
		//Item cost
		document.purchase_form.amount.value = item_cost;
		//Delivery cost
		document.purchase_form.shipping.value = delivery_cost;
		//Submit
		document.purchase_form.submit();
		} 
	
	    else 
	
	    {
		alert("Please select your payment options");
	    }
	}
	
	<!-- END PAYPAL PAYMENT -->
	
	<!--CASH PAYMENT -->
	
	if(paypal == false)
	
	{

  		if(delivery_complete == 1 && payment_complete == 1)
  
  		{
		alert("Cash payment process");
		
		saddle_cost =  parseFloat(saddle_cost);
		paypal_cost =  parseFloat(paypal_cost);
		
		item_cost = (saddle_cost + paypal_cost).toFixed(2);
		//Item cost
		document.cash.amount.value = item_cost;
		//Delivery cost
		document.cash.shipping.value = delivery_cost;
		//Submit
		document.cash.submit();
		} 
	
	    else 
	
	    {
		alert("Please select your payment options");
	    }
	}
	
	<!-- END PAYPAL PAYMENT -->
	
}